﻿@model Auction_Intranet.Models.AcceptInvitationModel

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm("AcceptInvitation", "Action", FormMethod.Post, new { @class = "accept-invitation-form black-shadow-box" }))
{
    <legend>Accept invitation from @Model.invitation.Group.Name</legend>
        <div class="accept-invitation-form-errors form-validation-display">   
             @Html.ValidationMessageFor(model => model.creditToAdd)
             <div class="accept-invitation-form-errors-script">  
                @Html.ValidationSummary(true)
             </div>
         </div>
        <div class="hide">
            @Html.EditorFor(model => model.invitation.Id)
        </div>
        <div class="hide">
            @Html.EditorFor(model => model.invitation.Group.Id)
            @Html.EditorFor(model => model.invitation.Group.Name)
        </div>
        <div class="hide available-credit">
            @Html.EditorFor(model => model.invitation.User.Balance)
        </div>
        <div class="amounts">
            <div class="editor-label">                 
                <p>@Html.LabelFor(model => model.creditToAdd)</p>
                <p>Available: $<span class="available-balance ">@Model.invitation.User.Balance</span></p>
            </div>
            <div class="editor-field spinner">                
                @Html.TextBoxFor(model => model.creditToAdd, new { @class = "spinner-accept-invite", autocomplete = "off", placeholder = "amount" })
            </div>
        </div>
        <div class="accept-invitation-form-button">            
            <input type="submit" value="Add" class="input-button"/> <input type="button" value="Cancel" class="input-button" onclick="javascript:document.location.href='@Url.Action("Invitations", "Action")'";"" />
        </div>    
}

<script type="text/javascript">
    $(function () {
        $(".spinner-accept-invite").spinner({
            max: $(".available-credit input").val(),
            min: 1
        });
    });    
</script>